cmake_minimum_required(VERSION 3.12)
project(gbmu C)

add_definitions(-DUSE_SDL)
# 添加头文件目录
include_directories(include)
# 源文件配置

FILE(GLOB_RECURSE src_source ./src/*.c ./src/*.cpp)
# 编译选项配置
set(CMAKE_C_STANDARD 99)
set(CMAKE_C_FLAGS_RELEASE "-march=native -O3 -Wextra -Wall -Wno-switch -flto")
set(CMAKE_C_FLAGS_DEBUG "-g -DDEBUG=1")

# SDL2 依赖配置
find_package(SDL2 REQUIRED)
include_directories(${SDL2_INCLUDE_DIRS})

# 可执行目标
# add_executable(gbmu ${src_source})

# 创建库目标
add_library(gbmu ${src_source})

# target_link_libraries(${PROJECT_NAME} mingw32)
# target_link_libraries(${PROJECT_NAME} SDL2main)
# target_link_libraries(${PROJECT_NAME} SDL2)

# 头文件包含配置（关键修正）
target_include_directories(gbmu PUBLIC
    $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>  # 构建时路径
    $<INSTALL_INTERFACE:${INC_INSTALL_DIR}>            # 安装后路径
)

install(DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/inc/"
    DESTINATION "${INC_INSTALL_DIR}/gbmu"
    FILES_MATCHING PATTERN "*.h"
)